package com.xukai.springboot.datalayer.statis;

import com.xukai.springboot.entity.statistics.t_statis_chart_datasource;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ChartDataSourceMapper {

    /**
     * 获取数据源列表
     */
    @Select("select a.id as chartID ,a.chartName ,c.id as dataSourceID ,c.dataSourceName from t_statis_chart_setting a \n" +
            "join t_statis_chart_datasource b on a.id=b.chartID\n" +
            "join t_statis_datasource c on b.dataSourceID=c.id \n" +
            "where a.id=#{chartID} \n")
    public List<t_statis_chart_datasource> GetDataSourceList(@Param("chartID") int chartID);

    /**
     * 添加数据源
     */
    @Insert("INSERT INTO t_statis_chart_datasource (chartID,dataSourceID)\n" +
            "values (#{chartID},#{dataSourceID})")
    public void AddDataSource(t_statis_chart_datasource data);

    /**
     * 清空数据源列表
     */
    @Delete(" DELETE FROM t_statis_chart_datasource where chartID=#{chartID}")
    public void ClearDataSource(@Param("chartID") int chartID);

}
